package com.fastloan.safe.mgt.user.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.kawins.base.baseabs.BaseModel;
import com.kawins.shiro.temp.achieve.iface.IShiroModel;
import com.kawins.spring.valid.annotation.IDCard;
import com.kawins.spring.valid.group.Group;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;

@Table(name = "CMU_USER")
public class CmuUser extends BaseModel<String> implements IShiroModel<String> {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NotBlank(groups = {Group.Update.class}, message = "ID不能为空")
    @Size(groups = {Group.Update.class}, min = 36, max = 36, message = "主键错误")
    private String id;

    /**
     * 工号
     */
    @Column(name = "CODE")
    private String code;

    /**
     * 用户名
     */
    @Column(name = "USERNAME")
    @NotBlank(groups = {Group.Insert.class}, message = "用户名不能为空")
    private String username;

    /**
     * 密码
     */
    @Column(name = "PASSWORD")
    @JSONField(serialize = false)
    private String password;

    /**
     * 中文名
     */
    @Column(name = "CNAME")
    @NotBlank(groups = {Group.Insert.class, Group.Update.class}, message = "中文名不能为空")
    private String cname;

    /**
     * 身份证
     */
    @Column(name = "ID_CARD")
    @IDCard(groups = {Group.Insert.class, Group.Update.class}, message = "身份证格式错误")
    private String idCard;

    /**
     * 手机号
     */
    @Column(name = "PHONE")
    private String phone;

    /**
     * 邮箱
     */
    @Column(name = "EMAIL")
    @Email(groups = {Group.Insert.class, Group.Update.class}, message = "邮箱格式不正确")
    private String email;

    /**
     * 上次登陆时间
     */
    @Column(name = "LAST_LOGIN_TIME")
    private Date lastLoginTime;

    /**
     * 上次更新密码时间
     */
    @Column(name = "CHANGE_PWD_TIME")
    @JSONField(serialize = false)
    private Date changePwdTime;

    /**
     * 头像
     */
    @Column(name = "USER_PROFILE")
    private String userProfile;

    /**
     * 0:正常1:锁定2:删除
     */
    @Column(name = "STATUS")
    private Integer status;

    /**
     * 创建时间
     */
    @Column(name = "CREATE_TIME")
    private Date createTime;

    /**
     * 创建人
     */
    @Column(name = "CREATE_BY")
    private String createBy;

    /**
     * 用户盐
     */
    @Column(name = "SALT")
    @JSONField(serialize = false)
    private String salt;

    /**
     * 是否为管理员
     */
    @Column(name = "ROOT_ROLE_ID")
    private String rootRoleId;

    /**
     * 登陆token
     */
    @Column(name = "TOKEN")
    @JSONField(serialize = false)
    private String token;

    /**
     * 身份证正面
     */
    @Column(name = "IDENTITY_FRONT")
    private String identityFront;

    /**
     * 身份证反面
     */
    @Column(name = "IDENTITY_SIDE")
    private String identitySide;

    /**
     * 0正常, 1未激活
     */
    @Column(name = "VERIFY")
    private Integer verify;

    public Integer getVerify() {
        return verify;
    }

    public void setVerify(Integer verify) {
        this.verify = verify;
    }

    public String getIdentityFront() {
        return identityFront;
    }

    public void setIdentityFront(String identityFront) {
        this.identityFront = identityFront;
    }

    public String getIdentitySide() {
        return identitySide;
    }

    public void setIdentitySide(String identitySide) {
        this.identitySide = identitySide;
    }

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public void setPassword(String password) {
        this.password = password;
    }

    public String getCname() {
        return cname;
    }

    public CmuUser setCname(String cname) {
        this.cname = cname;
        return this;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    @Override
    public String getPhone() {
        return phone;
    }

    @Override
    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String getEmail() {
        return email;
    }

    @Override
    public void setEmail(String email) {
        this.email = email;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public Date getChangePwdTime() {
        return changePwdTime;
    }

    public void setChangePwdTime(Date changePwdTime) {
        this.changePwdTime = changePwdTime;
    }

    public String getUserProfile() {
        return userProfile;
    }

    public void setUserProfile(String userProfile) {
        this.userProfile = userProfile;
    }

    @Override
    public Integer getStatus() {
        return status;
    }

    @Override
    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    @Override
    public String getSalt() {
        return salt;
    }

    @Override
    public void setSalt(String salt) {
        this.salt = salt;
    }

    @Override
    public String getGoogleToken() {
        return null;
    }

    @Override
    public void setGoogleToken(String s) {

    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getRootRoleId() {
        return rootRoleId;
    }

    public void setRootRoleId(String rootRoleId) {
        this.rootRoleId = rootRoleId;
    }

    @Override
    public String toString() {
        return "CmuUser{" +
                "id='" + id + '\'' +
                ", code='" + code + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", cname='" + cname + '\'' +
                ", idCard='" + idCard + '\'' +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", lastLoginTime=" + lastLoginTime +
                ", changePwdTime=" + changePwdTime +
                ", userProfile='" + userProfile + '\'' +
                ", status=" + status +
                ", createTime=" + createTime +
                ", createBy='" + createBy + '\'' +
                ", salt='" + salt + '\'' +
                ", rootRoleId='" + rootRoleId + '\'' +
                ", token='" + token + '\'' +
                '}';
    }
}